package model.game.maze;

import model.algorithms.IAction;
import model.algorithms.State;

public class MazeAction implements IAction {
	private int x;
	private int y;

	public MazeAction(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public State doAction(State state) {
		MazeState mazeState = (MazeState)state;
		MazeState newState = new MazeState(x, y);
		
		newState.addToX(mazeState.getX());
		newState.addToY(mazeState.getY());

		return newState;
	}

	public String getName() {
		if (x == 0 && y == 1) {
			return "(" + x + "," + y + ") South";
		}
		else if (x == 0 && y == -1) {
			return "(" + x + "," + y + ") North";
		}
		else if (x == 1 && y == 0) {
			return "(" + x + "," + y + ") East";
		}
		else if (x == -1 && y == 0) {
			return "(" + x + "," + y + ") West";
		}
		else if (x == 1 && y == 1) {
			return "(" + x + "," + y + ") South-East";
		}
		else if (x == 1 && y == -1) {
			return "(" + x + "," + y + ") North-East";
		}
		else if (x == -1 && y == 1) {
			return "(" + x + "," + y + ") South-West";
		}
		else if (x == -1 && y == -1) {
			return "(" + x + "," + y + ") North-West";
		}
		// Never going to happen!
		else {
			return "(" + x + "," + y + ")";
		}
	}
}
